﻿using System.Text;

using SqlExecHelper.Cache;

namespace SqlExecHelper.Query
{
        internal class SqlTopQuery : SqlQuery
        {
                public SqlTopQuery(string table, RunParam param, int topNum, ClassStructure column, string orderBy, params ISqlWhere[] where) : base(table, param, column, orderBy, where)
                {
                        this.TopNum = topNum;
                }
                public SqlTopQuery(string table, RunParam param, int topNum, params ISqlWhere[] where) : base(table, param, where)
                {
                        this.TopNum = topNum;
                }
                public SqlTopQuery(string table, RunParam param, int topNum, string column, string orderBy, params ISqlWhere[] where) : base(table, param, column, orderBy, where)
                {
                        this.TopNum = topNum;
                }
                public SqlTopQuery (RunParam param, UnionQueryParam union, string prefix, ClassStructure column) : base (param, union, prefix, column)
                {
                        this.TopNum = union.TopNum;
                }
                public SqlTopQuery(RunParam param, UnionQueryParam union, string prefix, ClassStructure column,string extendCol) : base(param, union, prefix, column, extendCol)
                {
                        this.TopNum = union.TopNum;
                }
                public SqlTopQuery (RunParam param, UnionQueryParam union, string prefix, string column) : base (param, union, prefix, column)
                {
                        this.TopNum = union.TopNum;
                }
                public int? TopNum
                {
                        get;
                }
                protected override void _InitHead(StringBuilder sql)
                {
                        if (this.TopNum.HasValue)
                        {
                                SqlTools.InitHead (sql, this.TopNum.Value);
                        }
                }
        }
}
